IrTransformer

abstract class IrTransformer(context: IrPluginContext, messageCollector: MessageCollector) : IrElementTransformerVoidWithContext, FileLoweringPass, HasContext, KnowsCurrentFile

Functions

asConst
Link copied to clipboard
open fun Boolean.asConst(type: IrType = context.irBuiltIns.booleanType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Boolean>
open fun Byte.asConst(type: IrType = context.irBuiltIns.byteType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Byte>
open fun Char.asConst(type: IrType = context.irBuiltIns.charType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Char>
open fun Double.asConst(type: IrType = context.irBuiltIns.doubleType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Double>
open fun Float.asConst(type: IrType = context.irBuiltIns.floatType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Float>
open fun Int.asConst(type: IrType = context.irBuiltIns.intType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Int>
open fun Long.asConst(type: IrType = context.irBuiltIns.longType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Long>
open fun Short.asConst(type: IrType = context.irBuiltIns.shortType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Short>
open fun String.asConst(type: IrType = context.irBuiltIns.stringType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<String>
buildLambda
Link copied to clipboard
open fun IrBuilderWithScope.buildLambda(returnType: IrType?, funBuilder: IrFunctionBuilder.() -> Unit = {}, funApply: IrSimpleFunction.() -> Unit): IrSimpleFunction

Builds a local function to be used as a lambda, likely with lambdaArgument Return type must be specified at some point, but may be passed as null and specified later. Will be automatically set if the lambda has an expression body and it wasn't set in funBuilder or funApply

buildStatement
Link copied to clipboard
open fun <T : IrElement> IrSymbolOwner.buildStatement(startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET, origin: IrStatementOrigin? = null, block: IrSingleStatementBuilder.() -> T): T
createIrBuilder
Link copied to clipboard
open fun createIrBuilder(symbol: IrSymbol, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): DeclarationIrBuilder
createIrBuilderAt
Link copied to clipboard
open fun IrSymbolOwner.createIrBuilderAt(): DeclarationIrBuilder
invoke
Link copied to clipboard
open operator fun <R : IrBindableSymbol<*, *>> Reference<R>.invoke(): R
open operator fun TypeRef.invoke(): IrType
irCall
Link copied to clipboard
open fun IrBuilderWithScope.irCall(funcRef: FunctionRef): IrCall
open fun IrBuilderWithScope.irCall(funcRef: FunctionRef, type: IrType): IrCall
isSubclassOf
Link copied to clipboard
open fun IrClass.isSubclassOf(klass: ClassRef): Boolean
open fun IrType.isSubclassOf(klass: ClassRef): Boolean
lambdaArgument
Link copied to clipboard
open fun lambdaArgument(lambda: IrSimpleFunction, type: IrType = run { //TODO workaround for https://youtrack.jetbrains.com/issue/KT-46896 val base = if (lambda.isSuspend) context.referenceClass( StandardNames.getSuspendFunctionClassId(lambda.allParameters.size).asSingleFqName() ) ?: error("suspend function type not found") else context.referenceClass(StandardNames.getFunctionClassId(lambda.allParameters.size).asSingleFqName()) ?: error("function type not found") base.typeWith(lambda.allParameters.map { it.type } + lambda.returnType) }, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrFunctionExpression

Creates a IrFunctionExpressionImpl from the given function, auto-inferring the type if not specified

lower
Link copied to clipboard
open override fun lower(irFile: IrFile)
messageLocation
Link copied to clipboard
open fun IrElement.messageLocation(): CompilerMessageSourceLocation?

Get the message location for an element

nullConst
Link copied to clipboard
open fun nullConst(type: IrType, startOffset: Int = UNDEFINED_OFFSET, endOffset: Int = UNDEFINED_OFFSET): IrConst<Nothing?>
report
Link copied to clipboard
open fun MessageCollector.report(message: String, level: CompilerMessageSeverity, location: CompilerMessageSourceLocation?)

Report a message

reportAt
Link copied to clipboard
open fun MessageCollector.reportAt(message: String, level: CompilerMessageSeverity, location: IrElement)

Report a message at the given element

reportError
Link copied to clipboard
open fun MessageCollector.reportError(message: String, location: CompilerMessageSourceLocation?)
open fun MessageCollector.reportError(message: String, location: IrElement)
reportInfo
Link copied to clipboard
open fun MessageCollector.reportInfo(message: String, location: CompilerMessageSourceLocation?)
open fun MessageCollector.reportInfo(message: String, location: IrElement)
reportWarning
Link copied to clipboard
open fun MessageCollector.reportWarning(message: String, location: CompilerMessageSourceLocation?)
open fun MessageCollector.reportWarning(message: String, location: IrElement)
resolve
Link copied to clipboard
open fun <R : IrBindableSymbol<*, *>> Reference<R>.resolve(): R
open fun TypeRef.resolve(): IrType
resolveOrNull
Link copied to clipboard
open fun <R : IrBindableSymbol<*, *>> Reference<R>.resolveOrNull(): R?
resolveTypeWith
Link copied to clipboard
open fun ClassRef.resolveTypeWith(vararg arguments: IrType): IrSimpleType
toIr
Link copied to clipboard
open fun KotlinType.toIr(): IrType
visitAnonymousInitializer
Link copied to clipboard
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrStatement
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?): IrStatement
visitAnonymousInitializerNew
Link copied to clipboard
open fun visitAnonymousInitializerNew(declaration: IrAnonymousInitializer): IrStatement
visitBlock
Link copied to clipboard
open fun visitBlock(expression: IrBlock): IrExpression
override fun visitBlock(expression: IrBlock, data: Nothing?): IrExpression
visitBlockBody
Link copied to clipboard
open fun visitBlockBody(body: IrBlockBody): IrBody
override fun visitBlockBody(body: IrBlockBody, data: Nothing?): IrBody
visitBody
Link copied to clipboard
open fun visitBody(body: IrBody): IrBody
override fun visitBody(body: IrBody, data: Nothing?): IrBody
visitBranch
Link copied to clipboard
open fun visitBranch(branch: IrBranch): IrBranch
override fun visitBranch(branch: IrBranch, data: Nothing?): IrBranch
visitBreak
Link copied to clipboard
open fun visitBreak(jump: IrBreak): IrExpression
override fun visitBreak(jump: IrBreak, data: Nothing?): IrExpression
visitBreakContinue
Link copied to clipboard
open fun visitBreakContinue(jump: IrBreakContinue): IrExpression
override fun visitBreakContinue(jump: IrBreakContinue, data: Nothing?): IrExpression
visitCall
Link copied to clipboard
open fun visitCall(expression: IrCall): IrExpression
override fun visitCall(expression: IrCall, data: Nothing?): IrExpression
visitCallableReference
Link copied to clipboard
open fun visitCallableReference(expression: IrCallableReference<*>): IrExpression
override fun visitCallableReference(expression: IrCallableReference<*>, data: Nothing?): IrExpression
visitCatch
Link copied to clipboard
open fun visitCatch(aCatch: IrCatch): IrCatch
override fun visitCatch(aCatch: IrCatch, data: Nothing?): IrCatch
visitClass
Link copied to clipboard
override fun visitClass(declaration: IrClass): IrStatement
override fun visitClass(declaration: IrClass, data: Nothing?): IrStatement
visitClassNew
Link copied to clipboard
open fun visitClassNew(declaration: IrClass): IrStatement
visitClassReference
Link copied to clipboard
open fun visitClassReference(expression: IrClassReference): IrExpression
override fun visitClassReference(expression: IrClassReference, data: Nothing?): IrExpression
visitComposite
Link copied to clipboard
open fun visitComposite(expression: IrComposite): IrExpression
override fun visitComposite(expression: IrComposite, data: Nothing?): IrExpression
visitConst
Link copied to clipboard
open fun <T> visitConst(expression: IrConst<T>): IrExpression
override fun <T> visitConst(expression: IrConst<T>, data: Nothing?): IrExpression
visitConstructor
Link copied to clipboard
open fun visitConstructor(declaration: IrConstructor): IrStatement
override fun visitConstructor(declaration: IrConstructor, data: Nothing?): IrStatement
visitConstructorCall
Link copied to clipboard
open fun visitConstructorCall(expression: IrConstructorCall): IrExpression
override fun visitConstructorCall(expression: IrConstructorCall, data: Nothing?): IrExpression
visitContainerExpression
Link copied to clipboard
open fun visitContainerExpression(expression: IrContainerExpression): IrExpression
override fun visitContainerExpression(expression: IrContainerExpression, data: Nothing?): IrExpression
visitContinue
Link copied to clipboard
open fun visitContinue(jump: IrContinue): IrExpression
override fun visitContinue(jump: IrContinue, data: Nothing?): IrExpression
visitDeclaration
Link copied to clipboard
open fun visitDeclaration(declaration: IrDeclarationBase): IrStatement
override fun visitDeclaration(declaration: IrDeclarationBase, data: Nothing?): IrStatement
visitDeclarationReference
Link copied to clipboard
open fun visitDeclarationReference(expression: IrDeclarationReference): IrExpression
override fun visitDeclarationReference(expression: IrDeclarationReference, data: Nothing?): IrExpression
visitDelegatingConstructorCall
Link copied to clipboard
open fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall, data: Nothing?): IrExpression
visitDoWhileLoop
Link copied to clipboard
open fun visitDoWhileLoop(loop: IrDoWhileLoop): IrExpression
override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: Nothing?): IrExpression
visitDynamicExpression
Link copied to clipboard
open fun visitDynamicExpression(expression: IrDynamicExpression): IrExpression
override fun visitDynamicExpression(expression: IrDynamicExpression, data: Nothing?): IrExpression
visitDynamicMemberExpression
Link copied to clipboard
open fun visitDynamicMemberExpression(expression: IrDynamicMemberExpression): IrExpression
override fun visitDynamicMemberExpression(expression: IrDynamicMemberExpression, data: Nothing?): IrExpression
visitDynamicOperatorExpression
Link copied to clipboard
open fun visitDynamicOperatorExpression(expression: IrDynamicOperatorExpression): IrExpression
override fun visitDynamicOperatorExpression(expression: IrDynamicOperatorExpression, data: Nothing?): IrExpression
visitElement
Link copied to clipboard
open fun visitElement(element: IrElement): IrElement
override fun visitElement(element: IrElement, data: Nothing?): IrElement
visitElseBranch
Link copied to clipboard
open fun visitElseBranch(branch: IrElseBranch): IrElseBranch
override fun visitElseBranch(branch: IrElseBranch, data: Nothing?): IrElseBranch
visitEnumConstructorCall
Link copied to clipboard
open fun visitEnumConstructorCall(expression: IrEnumConstructorCall): IrExpression
override fun visitEnumConstructorCall(expression: IrEnumConstructorCall, data: Nothing?): IrExpression
visitEnumEntry
Link copied to clipboard
open fun visitEnumEntry(declaration: IrEnumEntry): IrStatement
override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?): IrStatement
visitErrorCallExpression
Link copied to clipboard
open fun visitErrorCallExpression(expression: IrErrorCallExpression): IrExpression
override fun visitErrorCallExpression(expression: IrErrorCallExpression, data: Nothing?): IrExpression
visitErrorDeclaration
Link copied to clipboard
open fun visitErrorDeclaration(declaration: IrErrorDeclaration): IrStatement
override fun visitErrorDeclaration(declaration: IrErrorDeclaration, data: Nothing?): IrStatement
visitErrorExpression
Link copied to clipboard
open fun visitErrorExpression(expression: IrErrorExpression): IrExpression
override fun visitErrorExpression(expression: IrErrorExpression, data: Nothing?): IrExpression
visitExpression
Link copied to clipboard
open fun visitExpression(expression: IrExpression): IrExpression
override fun visitExpression(expression: IrExpression, data: Nothing?): IrExpression
visitExpressionBody
Link copied to clipboard
open fun visitExpressionBody(body: IrExpressionBody): IrBody
override fun visitExpressionBody(body: IrExpressionBody, data: Nothing?): IrBody
visitExternalPackageFragment
Link copied to clipboard
open fun visitExternalPackageFragment(declaration: IrExternalPackageFragment): IrExternalPackageFragment
override fun visitExternalPackageFragment(declaration: IrExternalPackageFragment, data: Nothing?): IrExternalPackageFragment
visitField
Link copied to clipboard
override fun visitField(declaration: IrField): IrStatement
override fun visitField(declaration: IrField, data: Nothing?): IrStatement
visitFieldAccess
Link copied to clipboard
open fun visitFieldAccess(expression: IrFieldAccessExpression): IrExpression
override fun visitFieldAccess(expression: IrFieldAccessExpression, data: Nothing?): IrExpression
visitFieldNew
Link copied to clipboard
open fun visitFieldNew(declaration: IrField): IrStatement
visitFile
Link copied to clipboard
override fun visitFile(declaration: IrFile): IrFile
override fun visitFile(declaration: IrFile, data: Nothing?): IrFile
visitFileNew
Link copied to clipboard
open fun visitFileNew(declaration: IrFile): IrFile
visitFunction
Link copied to clipboard
override fun visitFunction(declaration: IrFunction): IrStatement
override fun visitFunction(declaration: IrFunction, data: Nothing?): IrStatement
visitFunctionAccess
Link copied to clipboard
open fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression
override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: Nothing?): IrExpression
visitFunctionExpression
Link copied to clipboard
open fun visitFunctionExpression(expression: IrFunctionExpression): IrExpression
override fun visitFunctionExpression(expression: IrFunctionExpression, data: Nothing?): IrElement
visitFunctionNew
Link copied to clipboard
open fun visitFunctionNew(declaration: IrFunction): IrStatement
visitFunctionReference
Link copied to clipboard
open fun visitFunctionReference(expression: IrFunctionReference): IrExpression
override fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): IrElement
visitGetClass
Link copied to clipboard
open fun visitGetClass(expression: IrGetClass): IrExpression
override fun visitGetClass(expression: IrGetClass, data: Nothing?): IrExpression
visitGetEnumValue
Link copied to clipboard
open fun visitGetEnumValue(expression: IrGetEnumValue): IrExpression
override fun visitGetEnumValue(expression: IrGetEnumValue, data: Nothing?): IrExpression
visitGetField
Link copied to clipboard
open fun visitGetField(expression: IrGetField): IrExpression
override fun visitGetField(expression: IrGetField, data: Nothing?): IrExpression
visitGetObjectValue
Link copied to clipboard
open fun visitGetObjectValue(expression: IrGetObjectValue): IrExpression
override fun visitGetObjectValue(expression: IrGetObjectValue, data: Nothing?): IrExpression
visitGetValue
Link copied to clipboard
open fun visitGetValue(expression: IrGetValue): IrExpression
override fun visitGetValue(expression: IrGetValue, data: Nothing?): IrExpression
visitInstanceInitializerCall
Link copied to clipboard
open fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall): IrExpression
override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?): IrExpression
visitLocalDelegatedProperty
Link copied to clipboard
open fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrStatement
override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty, data: Nothing?): IrStatement
visitLocalDelegatedPropertyReference
Link copied to clipboard
open fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference, data: Nothing?): IrExpression
visitLoop
Link copied to clipboard
open fun visitLoop(loop: IrLoop): IrExpression
override fun visitLoop(loop: IrLoop, data: Nothing?): IrExpression
visitMemberAccess
Link copied to clipboard
open fun visitMemberAccess(expression: IrMemberAccessExpression<*>): IrExpression
override fun visitMemberAccess(expression: IrMemberAccessExpression<*>, data: Nothing?): IrExpression
visitModuleFragment
Link copied to clipboard
open fun visitModuleFragment(declaration: IrModuleFragment): IrModuleFragment
override fun visitModuleFragment(declaration: IrModuleFragment, data: Nothing?): IrModuleFragment
visitPackageFragment
Link copied to clipboard
open override fun visitPackageFragment(declaration: IrPackageFragment): IrPackageFragment
override fun visitPackageFragment(declaration: IrPackageFragment, data: Nothing?): IrElement
visitProperty
Link copied to clipboard
override fun visitProperty(declaration: IrProperty): IrStatement
override fun visitProperty(declaration: IrProperty, data: Nothing?): IrStatement
visitPropertyNew
Link copied to clipboard
open fun visitPropertyNew(declaration: IrProperty): IrStatement
visitPropertyReference
Link copied to clipboard
open fun visitPropertyReference(expression: IrPropertyReference): IrExpression
override fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?): IrElement
visitRawFunctionReference
Link copied to clipboard
open fun visitRawFunctionReference(expression: IrRawFunctionReference): IrExpression
override fun visitRawFunctionReference(expression: IrRawFunctionReference, data: Nothing?): IrExpression
visitReturn
Link copied to clipboard
open fun visitReturn(expression: IrReturn): IrExpression
override fun visitReturn(expression: IrReturn, data: Nothing?): IrExpression
visitScript
Link copied to clipboard
override fun visitScript(declaration: IrScript): IrStatement
override fun visitScript(declaration: IrScript, data: Nothing?): IrStatement
visitScriptNew
Link copied to clipboard
open fun visitScriptNew(declaration: IrScript): IrStatement
visitSetField
Link copied to clipboard
open fun visitSetField(expression: IrSetField): IrExpression
override fun visitSetField(expression: IrSetField, data: Nothing?): IrExpression
visitSetValue
Link copied to clipboard
open fun visitSetValue(expression: IrSetValue): IrExpression
override fun visitSetValue(expression: IrSetValue, data: Nothing?): IrExpression
visitSimpleFunction
Link copied to clipboard
open fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement
override fun visitSimpleFunction(declaration: IrSimpleFunction, data: Nothing?): IrStatement
visitSingletonReference
Link copied to clipboard
open fun visitSingletonReference(expression: IrGetSingletonValue): IrExpression
override fun visitSingletonReference(expression: IrGetSingletonValue, data: Nothing?): IrExpression
visitSpreadElement
Link copied to clipboard
open fun visitSpreadElement(spread: IrSpreadElement): IrSpreadElement
override fun visitSpreadElement(spread: IrSpreadElement, data: Nothing?): IrSpreadElement
visitStringConcatenation
Link copied to clipboard
open fun visitStringConcatenation(expression: IrStringConcatenation): IrExpression
override fun visitStringConcatenation(expression: IrStringConcatenation, data: Nothing?): IrExpression
visitSuspendableExpression
Link copied to clipboard
open fun visitSuspendableExpression(expression: IrSuspendableExpression): IrExpression
override fun visitSuspendableExpression(expression: IrSuspendableExpression, data: Nothing?): IrExpression
visitSuspensionPoint
Link copied to clipboard
open fun visitSuspensionPoint(expression: IrSuspensionPoint): IrExpression
override fun visitSuspensionPoint(expression: IrSuspensionPoint, data: Nothing?): IrExpression
visitSyntheticBody
Link copied to clipboard
open fun visitSyntheticBody(body: IrSyntheticBody): IrBody
override fun visitSyntheticBody(body: IrSyntheticBody, data: Nothing?): IrBody
visitThrow
Link copied to clipboard
open fun visitThrow(expression: IrThrow): IrExpression
override fun visitThrow(expression: IrThrow, data: Nothing?): IrExpression
visitTry
Link copied to clipboard
open fun visitTry(aTry: IrTry): IrExpression
override fun visitTry(aTry: IrTry, data: Nothing?): IrExpression
visitTypeAlias
Link copied to clipboard
open fun visitTypeAlias(declaration: IrTypeAlias): IrStatement
override fun visitTypeAlias(declaration: IrTypeAlias, data: Nothing?): IrStatement
visitTypeOperator
Link copied to clipboard
open fun visitTypeOperator(expression: IrTypeOperatorCall): IrExpression
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Nothing?): IrExpression
visitTypeParameter
Link copied to clipboard
open fun visitTypeParameter(declaration: IrTypeParameter): IrStatement
override fun visitTypeParameter(declaration: IrTypeParameter, data: Nothing?): IrStatement
visitValueAccess
Link copied to clipboard
open fun visitValueAccess(expression: IrValueAccessExpression): IrExpression
override fun visitValueAccess(expression: IrValueAccessExpression, data: Nothing?): IrExpression
visitValueParameter
Link copied to clipboard
override fun visitValueParameter(declaration: IrValueParameter): IrStatement
override fun visitValueParameter(declaration: IrValueParameter, data: Nothing?): IrStatement
visitValueParameterNew
Link copied to clipboard
open fun visitValueParameterNew(declaration: IrValueParameter): IrStatement
visitVararg
Link copied to clipboard
open fun visitVararg(expression: IrVararg): IrExpression
override fun visitVararg(expression: IrVararg, data: Nothing?): IrExpression
visitVariable
Link copied to clipboard
open fun visitVariable(declaration: IrVariable): IrStatement
override fun visitVariable(declaration: IrVariable, data: Nothing?): IrStatement
visitWhen
Link copied to clipboard
open fun visitWhen(expression: IrWhen): IrExpression
override fun visitWhen(expression: IrWhen, data: Nothing?): IrExpression
visitWhileLoop
Link copied to clipboard
open fun visitWhileLoop(loop: IrWhileLoop): IrExpression
override fun visitWhileLoop(loop: IrWhileLoop, data: Nothing?): IrExpression
withBuilder
Link copied to clipboard
open fun <T> IrSymbolOwner.withBuilder(block: DeclarationIrBuilder.() -> T): T

Properties

context
Link copied to clipboard
open override val context: IrPluginContext
factory
Link copied to clipboard
open val factory: IrFactory
file
Link copied to clipboard
open override val file: IrFile

Gets the current file

kotlin
Link copied to clipboard
open val IrBuilderWithScope.kotlin: StdlibBuilders

Get the standard library builders

messageCollector
Link copied to clipboard
val messageCollector: MessageCollector
stdlib
Link copied to clipboard
open val IrBuilderWithScope.stdlib: StdlibBuilders

Get the standard library builders

typeSystem
Link copied to clipboard
val typeSystem: IrTypeSystemContext

Sources

jvm source
Link copied to clipboard